using System.Data;
using ET;

namespace DA
{
    public class Import_DAL
    {
        private clsConnect cls = new clsConnect();

        #region Getdata
        public DataTable Search(string keywords)
        {
            return cls.Search("sp_tb_Import_Search", "@KEYWORDS", keywords);
        }
        public DataTable GetDataOrder()
        {
            return cls.GetData("sp_tb_Room_Detail_Import");
        }
        public DataTable GetDataOrderDetail(int id)
        {
            return cls.GetData_ID_Int("sp_tb_Room_Detail_Import_Detail", "@Id", id);
        }
        public DataTable GetOrderBuyCode()
        {
            return cls.GetData("sp_ImportOrder");
        }
        public DataTable GetOrderBuyImportTemp(int id)
        {
            return cls.GetData_ID_Int("sp_ImportOrderTemp", "@Order_Buy_Id", id);
        }
        public DataTable GetOrderBuyDetail(int id)
        {
            return cls.GetData_ID_Int("sp_tb_Order_Buy_Detail", "@Order_Buy_Id", id);
        }
        public DataTable GetBranch_Import(int id)
        {
            return cls.GetData_ID_Int("sp_tb_Branch_Import_0", "@User_Id", id);
        }
        public DataTable GetWarehouse_Import(int id_1,int id_2)
        {
            return cls.GetData_ID_Int_Int("sp_tb_Warehouse_Import_0", "@Branch_Id", "@User_Id", id_1, id_2);
        }
        public DataTable GetRoom_Import(int id_1,int id_2)
        {
            return cls.GetData_ID_Int_Int("sp_tb_Room_Import_0", "@Warehouse_Id", "@User_Id", id_1, id_2);
        }
        #endregion

        #region Insert
        public bool Inserttb_Import(Import_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Order_Buy_Detail_Id", data.Order_Buy_Detail_Id);
            cls.AddParameter("@Materials_Id", data.Materials_Id);
            cls.AddParameter("@Quality", data.Quality);
            cls.AddParameter("@Price", data.Price);
            cls.AddParameter("@User_Id", data.User_Id);
            cls.AddParameter("@Status", data.Status);
            cls.AddParameter("@DateBegin", data.DateBegin);
            cls.AddParameter("@Room_Id", data.Room_Id);
            cls.ExecuteNonQuery("sp_ImportOrder_Insert_Temp");
            return true;
        }
        #endregion

        #region Update
        public bool Updatetb_Import(Import_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Import_ID", data.Import_ID);
            cls.AddParameter("@Import_Invoice", data.Import_Invoice);
            cls.AddParameter("@Import_Date", data.Import_Date);
            cls.AddParameter("@Import_Provider", data.Import_Provider);
            cls.AddParameter("@Materials_ID", data.Materials_ID);
            cls.AddParameter("@Import_Quantity", data.Import_Quantity);
            cls.AddParameter("@Import_Price", data.Import_Price);
            cls.AddParameter("@Import_TotalCash", data.Import_TotalCash);
            cls.AddParameter("@Room_ID", data.Room_ID);
            cls.AddParameter("@Import_Note", data.Import_Note);
            cls.ExecuteNonQuery("sp_tb_Import_Update");
            return true;
        }
        #endregion

        #region Delete
        public bool Deletetb_Import(int id)
        {
            cls.Delete("sp_tb_Order_Buy_Import", "@Id", id);
            return true;
        }
        #endregion
    }
}